<%--
  Created by IntelliJ IDEA.
  User: 42962
  Date: 2021/6/3
  Time: 23:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>student</title>
</head>
<body>

<h2>查询学生信息：</h2>
<form action="${pageContext.request.contextPath}/findStudentByIdOrName" method="post">
    <select id="select" name="select">
        <option value="id">根据id查询：</option>
        <option value="name">根据name查询：</option>
    </select>

    <input type="text" name="idOrName"/>
    <input type="submit" value="查询"/>
</form>
<c:if test="${!empty id}">
    <table border="1px" cellspacing="0" width="100%">
        <tr>
            <th>id</th>
            <th>name</th>
            <th>age</th>
            <th>gender</th>
            <th>number</th>
            <th>address</th>
            <th>status</th>
            <th>修改</th>
            <th>删除</th>
        </tr>
        <tr>
            <td>${studentId.id}</td>
            <td>${studentId.name}</td>
            <td>${studentId.age}</td>
            <td>${studentId.gender}</td>
            <td>${studentId.number}</td>
            <td>${studentId.address}</td>
            <td>${studentId.status}</td>
            <td><a href="${pageContext.request.contextPath}/update?id=${studentId.id}">修改</a></td>
            <td><a href="${pageContext.request.contextPath}/deleteStudent?id=${studentId.id}">删除</a></td>
        </tr>
    </table>
</c:if>

<c:choose><c:when test="${!empty studentName}">
    <table border="1px" cellspacing="0" width="100%">
        <tr>
            <th>id</th>
            <th>name</th>
            <th>age</th>
            <th>gender</th>
            <th>number</th>
            <th>address</th>
            <th>status</th>
            <th>修改</th>
            <th>删除</th>
        </tr>
        <c:forEach var="studentName" items="${studentName}">
            <tr>
                <td>${studentName.id}</td>
                <td>${studentName.name}</td>
                <td>${studentName.age}</td>
                <td>${studentName.gender}</td>
                <td>${studentName.number}</td>
                <td>${studentName.address}</td>
                <td>${studentName.status}</td>
                <td><a href="${pageContext.request.contextPath}/update?id=${studentName.id}">修改</a></td>
                <td><a href="${pageContext.request.contextPath}/deleteStudent?id=${studentName.id}">删除</a></td>
            </tr>
        </c:forEach>
    </table>
</c:when>
</c:choose>

<c:if test="${empty id && empty name}">
    ${msg}
</c:if>
<br><br>

<h2>所有学生信息：</h2>
<c:choose><c:when test="${!empty stu}">
    <table border="1px" cellspacing="0" width="100%">
        <tr>
            <th>id</th>
            <th>name</th>
            <th>age</th>
            <th>gender</th>
            <th>number</th>
            <th>address</th>
            <th>status</th>
            <th>修改</th>
            <th>删除</th>
        </tr>
        <c:forEach var="student" items="${stu}">
            <tr>
                <td>${student.id}</td>
                <td>${student.name}</td>
                <td>${student.age}</td>
                <td>${student.gender}</td>
                <td>${student.number}</td>
                <td>${student.address}</td>
                <td>${student.status}</td>
                <td><a href="${pageContext.request.contextPath}/update?id=${student.id}">修改</a></td>
                <td><a href="${pageContext.request.contextPath}/deleteStudent?id=${student.id}">删除</a></td>
            </tr>
        </c:forEach>
    </table>
</c:when>
    <c:otherwise>没有任何信息！</c:otherwise></c:choose>
<br><br>

<h2>插入学生信息：</h2>
<form action="${pageContext.request.contextPath}/insertStudent" method="post">
    <%--id：<input id="id" type="text" name="id"><br>--%>
    <table border="0px">
        <tr>
            <td>name：</td>
            <td><input id="name" type="text" name="name"><br></td>
        </tr>
        <tr>
            <td>age：</td>
            <td><input id="age" type="text" name="age"><br></td>
        </tr>
        <tr>
            <td>gender：</td>
            <td><input id="gender" type="text" name="gender"><br></td>
        </tr>
        <tr>
            <td>number：</td>
            <td><input id="number" type="text" name="number"><br></td>
        </tr>
        <tr>
            <td>address：</td>
            <td><input id="address" type="text" name="address"><br></td>
        </tr>
        <tr>
            <td>status：</td>
            <td><input id="status" type="text" name="status"><br></td>
        </tr>
    </table>
    <input type="submit" value="插入">

</form>
</body>
</html>
